package com.hbvtc.xxxy.nikeSale.frames;

import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.SQLException;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;

import com.hbvtc.xxxy.nikeSale.models.Salesman;

public class ShopNike extends JFrame implements ActionListener{
	JButton btnSelect,btnInsert,btnUpdate,btnDel,btnBack;
	public ShopNike() {
		this.setTitle("商品信息界面");
		this.setSize(1000, 700);
		this.setLocationRelativeTo(null);
		this.setVisible(true);

		// 设置标题栏的图标
		ImageIcon imageIcon = new ImageIcon(getClass().getResource("01.png"));
		this.setIconImage(imageIcon.getImage());

		// 背景图片的路径
		String path = "images/001.jpg";
		ImageIcon background = new ImageIcon(path);
		// 把背景图片显示在一个标签里面
		JLabel label = new JLabel(background);
		// 把标签的大小位置设置为图片刚好填充整个面板
		label.setBounds(0, 0, this.getWidth(), this.getHeight());
		// 把内容窗格转化为JPanel，否则不能用方法setOpaque()来使内容窗格透明
		JPanel imagePanel = (JPanel) this.getContentPane();
		imagePanel.setOpaque(false);
		// 把背景图片添加到分层窗格的最底层作为背景
		this.getLayeredPane().add(label, new Integer(Integer.MIN_VALUE));
		this.setLayout(null);
		btnSelect = new JButton("查询所有商品信息");
		btnInsert = new JButton("添加商品信息");
		btnUpdate = new JButton("修改商品信息");
		btnDel = new JButton("删除商品信息");
		btnBack = new JButton("返  回");

		this.add(btnSelect);
		this.add(btnInsert);
		this.add(btnUpdate);
		this.add(btnDel);
		this.add(btnBack);

		btnSelect.setBounds(340, 100, 230, 50);
		btnSelect.setFont(new Font(null, 0, 24));
		btnInsert.setBounds(340, 210, 230, 50);
		btnInsert.setFont(new Font(null, 0,24));
		btnDel.setBounds(340, 330, 230, 50);
		btnDel.setFont(new Font(null, 0, 24));
		btnUpdate.setBounds(340, 440, 230, 50);
		btnUpdate.setFont(new Font(null, 0, 24));
		btnBack.setBounds(700, 550, 110, 40);
		btnBack.setFont(new Font(null, 0, 24));
		
		btnSelect.addActionListener(this);
		btnInsert.addActionListener(this);
		btnUpdate.addActionListener(this);
		btnDel.addActionListener(this);
		btnBack.addActionListener(this);

	}

	public static void main(String[] args) {
		new ShopNike().setVisible(true);
	}

	//触发事件监听器
	@Override
	public void actionPerformed(ActionEvent e) {
		// TODO Auto-generated method stub
		if(e.getSource()==btnSelect)
			try {
				new SelectShopNike();
			} catch (SQLException e1) {
				// TODO Auto-generated catch block
				e1.printStackTrace();
			}
	    if(e.getSource()==btnInsert)
		    new AddShopNike();
	    if(e.getSource()==btnUpdate)
			new UpdateShopNike();
	    if(e.getSource()==btnDel)
		    new DelShopNike();
	    if(e.getSource()==btnBack){
	    	dispose();
	    new SuccessSalesmanNike();
	    }
	}
	
}
